<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function fn(arr1){
            const arr=[]
            function fn2(arr1){
              try{
                arr1.forEach(item=>{
                    item.forEach(item=>{
                        arr.push(item)
                        if(item.children){
                            throw new Error('error')
                        }
                    })
                })
              }
              catch(e){}
            }
            fn2(arr1)
            return arr
        }
    </script>
</body>
</html>
